﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
using Intersoft.Controls.TreeGridAssist;
using System.Collections;

namespace CommunitySystem.Views
{
    public class TreeGridAssert
    {
        public static void Expand(ObservableCollection<TreeGridNodeItem> tree)
        {
            try
            {
                foreach (TreeGridNodeItem node in tree)
                {
                    node.IsExpanded = true;
                    foreach (TreeGridNodeItem node2 in node.Children)
                    {
                        node2.IsExpanded = true;
                    }
                }
            }
            catch (Exception)
            {

            }
        }

        public ObservableCollection<TreeGridNodeItem> TreeSource(IList list)
        {
            TreeGridDataSource ds = new TreeGridDataSource(list);
            return ds.Source;
        }

        public ObservableCollection<TreeGridNodeItem> TreeSource(IList list, string idField, string parentIdField)
        {
            FlatTreeBuilder builder = new FlatTreeBuilder();
            builder.IdField = idField;
            builder.ParentIdField = parentIdField;
            TreeGridDataSource ds = new TreeGridDataSource(list);
            return ds.Source;
        }

        public static TreeGridDataSource OrgTreeSource(IList list)
        {
            FlatTreeBuilder builder = new FlatTreeBuilder("OrgId", "OrgParentId");
            return new TreeGridDataSource(list, builder);
        }
    }
}
